﻿using mozhi.smarterp.Business.Enums;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;
using Volo.Abp.Application.Dtos;

namespace mozhi.smarterp.Business.Purchases.Order
{
    public class PurchaseOrderCreateDto
    {
        public Guid DepartmentId { get; set; }

        [Required]
        public DateTime Date { get; set; }

        /// <summary>
        /// 建议供应商
        /// </summary>
        [Required]
        public Guid SupplierId { get; set; }

        /// <summary>
        ///要货日期
        /// </summary>
        public DateTime RequiredDate { get; set; }

        public string Comment { get; set; }

        /// <summary>
        /// 订单类型
        /// </summary>
        [Required]
        public PurchaseOrderType Type { get; set; }

        [Required]
        public Guid CurrencyId { get; set; }

        [Required]
        public decimal ExchangeRate { get; set; }


        public bool IncludeTax { get; set; }

        /// <summary>
        /// 采购员
        /// </summary>
        [Required]
        public Guid PurchaserId { get; set; }

        public Guid? PaymentTermId { get; set; }

        public List<PurchaseOrderItemCreateDto> Items { get; set; }

        public List<PurchaseOrderAdvancePaymentCreateDto> AdvancePaymentItems { get; set; }
    }

    public class PurchaseOrderItemCreateDto 
    {
        [Required]
        public Guid ProductId { get; set; }

        /// <summary>
        /// 申请单位
        /// </summary>
        [Required]
        public Guid PurchaseUnitId { get; set; }

        /// <summary>
        /// 申请数量
        /// </summary>
        [Required]
        public decimal PurchaseQuantity { get; set; }

        /// <summary>
        /// 单价
        /// </summary>
        public decimal? Price { get; set; }

        public Guid? TaxRateId { get; set; }

        public bool IsGift { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; set; }
    }

    public class PurchaseOrderAdvancePaymentCreateDto
    {
        [Required]
        public decimal AdvancePaymentPercent { get;  set; }

        public int Index { get;  set; }
    }
}
